#include "libThreadPool.h"
#include <iostream>
#include <windows.h>

using namespace std;

mutex mu;

void func(int &t){ 
	t++; 
	mu.lock();
	cout<<t<<endl;
	mu.unlock();
	Sleep(1000);
} 

void func2(int t){
	t++;
	mu.lock();
	cout<<t<<endl;
	mu.unlock();
	Sleep(1000);
} 


int main(){
	ThreadPool pool(3);
	int arr[]={1,2,3,4,5,6,7,8,9,10};
	for(int i=0;i<10;++i)
		pool.addThreadRef(func,arr[i]);
	system("pause");
	for(int i=0;i<10;++i)
		cout<<arr[i]<<endl;
	system("pause");
	for(int i=0;i<10;++i){
		pool.addThread(func2,i);
	}
	system("pause");
}